<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>支付订单凭据管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/news.css"/>
    <style>
        li {
            list-style: inherit !important;
        }
    </style>
</head>

<body class="childrenBody">
<form class="layui-form" action="">
                                                                                    <div class="layui-form-item">
                    <label class="layui-form-label">用户ID</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入用户ID" class="layui-input"
                               id="userId">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">订单金额</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入订单金额" class="layui-input"
                               id="price">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">0未付款 1已付款 2取消支付 </label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入0未付款 1已付款 2取消支付 " class="layui-input"
                               id="status">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">收到支付的时间</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入收到支付的时间" class="layui-input"
                               id="payTime">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">支付类型 1支付宝 2微信 3余额（暂未开发）</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入支付类型 1支付宝 2微信 3余额（暂未开发）" class="layui-input"
                               id="payType">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">订单号</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入订单号" class="layui-input"
                               id="orderCode">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">订单类型 1购买课程 2购买积分商城(这张表不保存，在order表里保存 以后是通用) 3未开发</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入订单类型 1购买课程 2购买积分商城(这张表不保存，在order表里保存 以后是通用) 3未开发" class="layui-input"
                               id="orderType">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">目标ID</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入目标ID" class="layui-input"
                               id="targetId">
                    </div>
                </div>
                        
    <div class="layui-form-item">
        <div class="layui-input-block">
            <a style="display:none;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="edit"
               id="edit">立即修改</a>
            <a style="display:none;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="add" id="add">立即提交</a>
            <a class="layui-btn layui-btn-primary close">关闭</a>
        </div>
    </div>
</form>
<script type="text/javascript" src="../../js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/wangEditor.js"></script>
<script type="text/javascript" src="../../js/basic.js"></script>
<script>

    function edit() {
        var id = GetQueryString("id");
        var topM = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        $.ajax({
            type: "post",
            url: "/payorder/update",
            data: {
                                                                                                                            userId : $("#userId").val(),
                                                                                    price : $("#price").val(),
                                                                                    status : $("#status").val(),
                                                                                    payTime : $("#payTime").val(),
                                                                                    payType : $("#payType").val(),
                                                                                    orderCode : $("#orderCode").val(),
                                                                                    orderType : $("#orderType").val(),
                                                                                    targetId : $("#targetId").val(),
                                                id:id
    },
        dataType: "json",
                success
    :

        function (data) {
            backData(data, topM);
        }
    })
        ;
    }

    function add() {
        var topM = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        $.ajax({
            type: "post",
            url: "/payorder/save",
            data: {
                                                                                                                            userId : $("#userId").val(),
                                                                                    price : $("#price").val(),
                                                                                    status : $("#status").val(),
                                                                                    payTime : $("#payTime").val(),
                                                                                    payType : $("#payType").val(),
                                                                                    orderCode : $("#orderCode").val(),
                                                                                    orderType : $("#orderType").val(),
                                                                                    targetId : $("#targetId").val(),
                                                extra:
        1
    },
        dataType: "json",
                success
    :

        function (data) {
            backData(data, topM);
        }
    })

    };

    function backData(data, topM) {
        if (data.status == 0) {

            setTimeout(function () {
                layer.close(topM);
                top.layer.msg("修改成功！");
                //刷新父页面
                parent.getList({});
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            }, 500);
        } else {
            layer.close(topM);
            layer.msg(data.msg, {icon: 1});
        }
    }

    function begin() {
        var op = GetQueryString("op");
        if (op == "add") {
            $("#add").show();
            return;
        }
        if (op == "edit") {
            $("#edit").show();
        }
        var id = GetQueryString("id");
        $.ajax({
            type: "post",
            url: "/payorder/info",
            data: {
                id: id
            },
            dataType: "json",
            success: function (data) {
                if (data.status == 0) {
                    
                        $("#id").val(data.result.id);

                    
                        $("#createTime").val(data.result.createTime);

                    
                        $("#userId").val(data.result.userId);

                    
                        $("#price").val(data.result.price);

                    
                        $("#status").val(data.result.status);

                    
                        $("#payTime").val(data.result.payTime);

                    
                        $("#payType").val(data.result.payType);

                    
                        $("#orderCode").val(data.result.orderCode);

                    
                        $("#orderType").val(data.result.orderType);

                    
                        $("#targetId").val(data.result.targetId);

                                    } else {
                    layer.msg(data.msg, {icon: 1});
                }
            }
        });
    }

    //点击取消关闭当前弹窗
    $(".close").click(function () {
//当你在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    })

    layui.use(['form'], function () {
        var form = layui.form;
        //监听提交
        form.on('submit(add)', function (data) {
            add()
            return false;
        });

        //监听提交
        form.on('submit(edit)', function (data) {
            edit()
            return false;
        });
        begin();
    });

</script>
</body>
</html>